import API from '@/utils/request'
// 分页查询
export const sOrderPage = (pageWrapper) => {
	return API.post('/sOrder/page', pageWrapper)
}
// 状态订单计数
export const sOrderCount = (userId) => {
	return API.get('/sOrder/count', {
		params: { userId: userId }
	})
}
//订单提交()
export const submitSOrderBatch = (data) => {
	return API.post('/sOrder/submit', data)
}

//订单详情
export const sOrderDetail = (id) => {
	return API.get('/sOrder/' + id)
}
//发货
export const sOrderDeliver = (orderId) => {
	return API.put('/sOrder/', null, {
		params: { state: 2, orderId: orderId }
	})
}
// 已到达
export const sOrderPreReceive = (orderId) => {
	return API.put('/sOrder/', null, {
		params: { orderId, state: 3 }
	})
}

//申请退货
export const sOrderPreReturn = ({ orderId, reason }) => {
	return API.put('/sOrder/return', { orderId, reason })
}
// 同意退货
export const sOrderReturn = (orderId) => {
	return API.put('/sOrder/', null, {
		params: { orderId, state: -2 }
	})
}
//用户订单表
export const userSOrderPage = ({
	pageNum: pageNum,
	pageSize: pageSize,
	userId: userId,
	state: state
}) => {
	return API.post('/sOrder/page', {
		pageNum: pageNum,
		pageSize: pageSize,
		userId: userId,
		state: state
	})
}
//取消订单
export const sOrderCancel = (orderId) => {
	return API.delete('/sOrder/' + orderId)
}
// 确认收货
export const sOrderReceive = (orderId) => {
	return API.put('/sOrder/', null, {
		params: { orderId, state: 4 }
	})
}
